<?php
/**
 * +----------------------------------------------------------------------
 * | Author: 罗极
 * +----------------------------------------------------------------------
 * | Description: RouteUnit.php
 * +----------------------------------------------------------------------
 * | User: Administrator Date: 8/20/ 0020 Time: 14:37
 * +----------------------------------------------------------------------
 */

namespace Framework\Router;

class RouteUnit
{
    protected $url;
    protected $pattern;
    protected $callback;
    protected $method;
    protected $link;
    protected $module;
    protected $controller;
    protected $action;


    public function __construct(string $url, string $link, array $pattern, $callback, string $method)
    {
        $this->url      = $url;
        $this->callback = $callback;
        $this->pattern  = $pattern;
        $this->method   = $method;
        $this->link     = $link;
        $arr            = explode('@', $link);
        $this->module   = ucfirst($arr[0]);
        $arr            = explode('#', $arr[1]);
        $this->controller = ucfirst($arr[0]);
        $this->action   = lcfirst($arr[1]);
    }

    /**
     * @return string
     */
    public function getModule() : string
    {
        return $this->module;
    }

    /**
     * @return string
     */
    public function getController() : string
    {
        return $this->controller;
    }

    /**
     * @return string
     */
    public function getAction() : string
    {
        return $this->action;
    }


    public function getUrl() : string
    {
        return $this->url;
    }



    public function getPattern() : array
    {
        return $this->pattern;
    }



    public function getCallback()
    {
        return $this->callback;
    }



    public function getMethod() : string
    {
        return $this->method;
    }



}